package com.nlx.notes.module.controller.charts;

import com.nlx.notes.module.bean.vo.charts.ChartsDataVO;
import com.nlx.notes.module.service.charts.FlowChartsService;
import com.nlx.notes.support.context.UserHolder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/flow-charts-month")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class FlowChartsMonthController {

    final FlowChartsService flowChartsService;

    /**
     * 年度流水图表
     * @return MonthChartsVO
     */
    @GetMapping(value = "/v1/charts")
    public List<ChartsDataVO> yearCharts(@RequestParam(value = "year",required = false) String year) {
        String userPhone = UserHolder.getUserContext().getUserPhone();
        log.info("查询用户年度流水图表 -> {}", userPhone);
        return flowChartsService.monthCharts(year,UserHolder.getUserContext().getBookId(),UserHolder.getUserContext().getId());
    }
}
